

--migração do título em aberto
insert into BancoGerencial..ContaPagar(
DataMovimento,
DataVencimento,
CodFornecedor,
Valor, 
Parcela,
TotalParcela,
Observacao,
DataHoraUltimaGravacao,
UsuarioUltimaGravacao
)
select 
rec.DTLANC,
rec.DTVENC,
rec.CODCLI,
rec.VALORTOT,
'1',
'1',
'NF:' + NOTAFISCAL + '' + SUBSTRING(OBS, 1,160),
GETDATE(),
'MIGRAÇÃO'
from SaoJose2020..Pagar as rec
where rec.DTPAG is null
and rec.CODCLI > 0
and rec.CANCELADA is null
and rec.CODCLI IN (SELECT CODIGO FROM Fornecedor)


select * from SaoJose2020..Pagar where CODCLI = 174


update ContaPagar set CodEmp = 1

